package com.bilgeadam.oop.program;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 29, 2014 11:59:16 AM
 * @version 1.0.0
 */
public class Student implements Comparable {

	private int id;
	private String firstName;
	private String lastName;
	private int age;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		Student other = (Student) obj;
		if (id != other.id) return false;
		return true;
	}

	@Override
	public String toString() {
		return "Student [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", age=" + age + "]";
	}

	@Override
	public int compareTo(Object o) {
		int sonuc = 0;
		Student student = (Student) o;
		if (this.firstName.length() > student.getFirstName().length()) {
			sonuc = 1;
		} else if (this.firstName.length() < student.getFirstName().length()) {
			sonuc = -1;
		}
		return sonuc;
	}

}
